<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var arr = [1,2,3];

        var arrFn = (function fn(){
           var val = ''; 
           return  Object.defineProperties({},{
                arr:{
                    value:[1,2,3]
                },
                sum:{
                    get(){
                        return val || 'abc';
                    },
                    set(v){
                        var sumVal = 0;
                        v.forEach(function(item){
                            sumVal+=item;
                        })
                        val = sumVal;
                    }
                },
                avarge:{
                    get(){
                        console.log(this);
                        return this.sum/this.arr.length;
                    }
                    
                }
            })
        })();


        arrFn.sum = arr;

        // arrFn.avarge = arr;

        console.log(arrFn.avarge);

        console.log(arrFn.sum);

    </script>
</body>
</html>